package com.jetpackframework.rxmvvm;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProvider;

import com.jetpackframework.base.BaseFragment;
import com.jetpackframework.ioc.IViewBind;


public abstract class BaseRxMvvmFragment<VM extends ViewModel,V extends IViewBind> extends BaseFragment<V> implements IViewModelProvider{
    protected VM viewModel;
    private ViewModelProvider viewModelProvider;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewModelProvider = new ViewModelProvider(this);
        viewModel = viewModelProvider.get(getViewModelClass());
        getLifecycle().addObserver(viewModel);

    }

    @Override
    public ViewModelProvider getViewModelProvider() {
        return viewModelProvider;
    }

    protected abstract Class<VM> getViewModelClass();

}
